package com.hundsun.cprs.yyt.service.goods.dto;

import com.hundsun.cprs.yyt.service.classify.domain.Classify;
import com.hundsun.cprs.yyt.service.goods.domain.Goods;
import com.hundsun.cprs.yyt.service.goods.domain.GoodsImage;
import com.hundsun.cprs.yyt.service.goods.domain.GoodsSpecs;

import java.util.List;

public class GoodsInfo extends Goods {
    private Classify classify;
    private List<GoodsImage> imageList;
    private List<GoodsSpecs> skus;

    public Classify getClassify() {
        return classify;
    }

    public void setClassify(Classify classify) {
        this.classify = classify;
    }

    public List<GoodsImage> getImageList() {
        return imageList;
    }

    public void setImageList(List<GoodsImage> imageList) {
        this.imageList = imageList;
    }

    public String obtainThumbnail(){
        if(getImageList() != null && getImageList().size() > 0){
            String thumbnail = null;
            for(GoodsImage image : getImageList()){
                if (thumbnail == null) {
                    //默认取列表的第一张
                    thumbnail = image.getOriginalImageUrl();
                }
                if (image.getImageType() != null && image.getImageType() == 1) {
                    //取首图
                    thumbnail = image.getOriginalImageUrl();
                }
            }
            return thumbnail;
        }
        return null;
    }

    public List<GoodsSpecs> getSkus() {
        return skus;
    }

    public void setSkus(List<GoodsSpecs> skus) {
        this.skus = skus;
    }
}
